package com.peenongsaban.freelance.action;

import com.opensymphony.xwork2.ActionSupport;
import com.peenongsaban.freelance.bean.RegisterBean;
import com.peenongsaban.freelance.model.MyJobModel;
import com.peenongsaban.freelance.service.MyJobService;
import com.peenongsaban.freelance.utils.ConstantUtils;
import com.peenongsaban.freelance.utils.SessionUtils;

public class MyJobAction extends ActionSupport{
	private static final long serialVersionUID = 1L;
	private MyJobModel model = new MyJobModel();
	
	public String myJob(){
		RegisterBean bean = (RegisterBean) SessionUtils.getSession(ConstantUtils.SESSION_LOGIN);
		if(bean==null){
			bean = new RegisterBean();
		}
		model.getUser().setIdCard(bean.getUser().getIdCard());

		MyJobService service = new MyJobService();		
		model.setListCategoryJob(service.getListJobCategoryJob());
		model.setListMyPostJob(service.getListMyPostJob(model));
		model.setListMyRequestJob(service.getListMyRequestJob(model));
		model.setPagePostJob(service.pagingPostJob(model));
		model.setPageRequestJob(service.pagingRequstJob(model));
		model.setListLastJob(service.getListLastPostJob());
		model.setAllMyPostJob(service.allMyPostJob(bean.getUser().getIdCard()));
		model.setAllMyRequestJob(service.allMyRequestJob(bean.getUser().getIdCard()));
		model.setRequestJobRequestStatus(service.getListRequestJobByRequestStatus(bean.getUser().getIdCard()));
		model.setRequestJobConfirmStatus(service.getListRequestJobByConfirmStatus(bean.getUser().getIdCard()));
		model.setRequestJobRejectStatus(service.getListRequestJobByRejectStatus(bean.getUser().getIdCard()));
		model.setListBeEmployed(service.getlistBeEmployed(bean.getUser().getIdCard()));
		
		return SUCCESS;
	}
	
	public MyJobModel getModel() {
		return model;
	}
	public void setModel(MyJobModel model) {
		this.model = model;
	}
	
}
